home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hardcore Visual Basic 5.0 (2nd Edition)
/
Hardcore Visual Basic 5.0 - Second Edition (1997)(Microsoft Press).iso
/
Code
/
CtlTool.bas
< prev
next >
Wrap
BASIC Source File
|
1997-06-14
|
1KB
|
42 lines
Attribute VB_Name = "MCtlTool"
Option Explicit
Function UniqueControlName(sPrefix As String, Ext As Object) As String
Dim v As Variant, s As String, c As Long, fFound As Boolean
On Error GoTo UniqueControlNameFail
s = sPrefix
Do
fFound = False
' Search for a control with the proposed prefix name
For Each v In Ext.Container.Controls
If v.Name = s Then
' Nope, try another name
fFound = True
c = c + 1
s = sPrefix & c
Exit For
End If
Next
Loop Until fFound = False
' Use this name
UniqueControlName = s
Exit Function
UniqueControlNameFail:
' Failure probably means no Extender.Container.Controls
UniqueControlName = sPrefix
End Function
' This function returns 0/1 rather than True/False for
' easier use with check boxes.
Private Function CheckBit(iValue As Integer, iBitPos As Integer) As Integer
If iValue And (2 ^ iBitPos) Then
CheckBit = 1
Else
CheckBit = 0
End If
End Function